package model

var RepositoryNames = struct { // repositories
	BlogAuthor       string
	BlogMedia        string
	BlogPage         string
	BlogPageDetail   string
	BlogPost         string
	BlogPostDetail   string
	BlogBook         string
	BlogBookMeta     string
	BlogBookDetail   string
	BlogBookRelation string
	BlogTerm         string
	BlogReactionLog  string
}{
	BlogAuthor:       "BlogAuthor",
	BlogMedia:        "BlogMedia",
	BlogPage:         "BlogPage",
	BlogPageDetail:   "BlogPageDetail",
	BlogPost:         "BlogPost",
	BlogPostDetail:   "BlogPostDetail",
	BlogBook:         "BlogBook",
	BlogBookMeta:     "BlogBookMeta",
	BlogBookDetail:   "BlogBookDetail",
	BlogBookRelation: "BlogBookRelation",
	BlogTerm:         "BlogTerm",
	BlogReactionLog:  "BlogReactionLog",
}

var RepositoryPreloadMap = map[string]map[string]string{
	RepositoryNames.BlogAuthor: {
		"Id":             BlogUserColumns.ID,
		"DatabaseId":     BlogUserColumns.UserID,
		"Name":           BlogUserColumns.UserNicename,
		"Nicename":       BlogUserColumns.UserNicename,
		"Uri":            BlogUserColumns.UserURL,
		"Url":            BlogUserColumns.UserURL,
		"RegisteredDate": BlogUserColumns.UserRegisteredAt,
		"Username":       BlogUserColumns.DisplayName,
	},
	RepositoryNames.BlogMedia: {
		"Uid":          BlogAttachmentRelationshipColumns.AttachmentRelationshipID,
		"Id":           BlogAttachmentRelationshipColumns.AttachmentID,
		"Uri":          BlogAttachmentRelationshipColumns.AttachmentSource,
		"Url":          BlogAttachmentRelationshipColumns.AttachmentImageURL,
		"Thumbnail":    BlogAttachmentRelationshipColumns.AttachmentThumbnail,
		"Order":        BlogAttachmentRelationshipColumns.AttachmentOrder,
		"altText":      BlogAttachmentRelationshipColumns.AttachmentImageAlt,
		"sourceUrl":    BlogAttachmentRelationshipColumns.AttachmentImageURL,
		"mediaDetails": BlogAttachmentRelationshipColumns.AttachmentImageMeta,
	},
	RepositoryNames.BlogPage: {
		"Id":            BlogPageColumns.ID,
		"AuthorId":      BlogPageColumns.PostAuthorID,
		"ParentId":      BlogPageColumns.PostParentID,
		"Title":         BlogPageColumns.PostTitle,
		"Excerpt":       BlogPageColumns.PostExcerpt,
		"Status":        BlogPageColumns.PostStatus,
		"CommentStatus": BlogPageColumns.CommentStatus,
		"Slug":          BlogPageColumns.PostName,
		"Uri":           BlogPageColumns.PostName,
		"Date":          BlogPageColumns.PostDate,
		"DateGmt":       BlogPageColumns.PostDateGMT,
		"Modified":      BlogPageColumns.PostModifiedDate,
		"ModifiedGmt":   BlogPageColumns.PostModifiedGMT,
		"CommentCount":  BlogPageColumns.CommentCount,
		"SortOrder":     BlogPageColumns.MenuOrder,
	},
	RepositoryNames.BlogPageDetail: {
		"ContentHtml": BlogPageDetailColumns.PostContent,
		"Content":     BlogPageDetailColumns.PostContentFiltered,
	},
	RepositoryNames.BlogPost: {
		"Id":            BlogPostColumns.ID,
		"AuthorId":      BlogPostColumns.PostAuthorID,
		"ParentId":      BlogPostColumns.PostParentID,
		"Title":         BlogPostColumns.PostTitle,
		"Excerpt":       BlogPostColumns.PostExcerpt,
		"Status":        BlogPostColumns.PostStatus,
		"CommentStatus": BlogPostColumns.CommentStatus,
		"Slug":          BlogPostColumns.PostName,
		"Uri":           BlogPostColumns.GUID,
		"Link":          BlogPostColumns.GUID,
		"Date":          BlogPostColumns.PostDate,
		"DateGmt":       BlogPostColumns.PostDateGMT,
		"Modified":      BlogPostColumns.PostModifiedDate,
		"ModifiedGmt":   BlogPostColumns.PostModifiedGMT,
		"CommentCount":  BlogPostColumns.CommentCount,
	},
	RepositoryNames.BlogPostDetail: {
		"ContentHtml": BlogPostDetailColumns.PostContent,
		"Content":     BlogPostDetailColumns.PostContentFiltered,
	},
	RepositoryNames.BlogBook: {
		"Id":            BlogKnowledgeBasisColumns.ID,
		"ParentId":      BlogKnowledgeBasisColumns.PostParentID,
		"AuthorId":      BlogKnowledgeBasisColumns.PostAuthorID,
		"SectionId":     BlogKnowledgeBasisColumns.SectionID,
		"Title":         BlogKnowledgeBasisColumns.PostTitle,
		"Excerpt":       BlogKnowledgeBasisColumns.PostExcerpt,
		"Status":        BlogKnowledgeBasisColumns.PostStatus,
		"CommentStatus": BlogKnowledgeBasisColumns.CommentStatus,
		"Slug":          BlogKnowledgeBasisColumns.PostName,
		"Uri":           BlogKnowledgeBasisColumns.GUID,
		"Link":          BlogKnowledgeBasisColumns.GUID,
		"PublicDate":    BlogKnowledgeBasisColumns.PublicDate,
		"Date":          BlogKnowledgeBasisColumns.PostDate,
		"Modified":      BlogKnowledgeBasisColumns.PostModifiedDate,
		"CommentCount":  BlogKnowledgeBasisColumns.CommentCount,
		"Sort":          BlogKnowledgeBasisColumns.MenuOrder,
		"year":          BlogKnowledgeBasisColumns.MenuOrder,
		"Sticky":        BlogKnowledgeBasisColumns.StickyType,
		"sticky":        BlogTermRelationshipColumns.StickyType, // 小写字母开头的都是中间表字段
		"logId":         BlogUserClickLogColumns.ClickLogID,
		"logSlug":       BlogUserClickLogColumns.SectionID,
		"logType":       BlogUserClickLogColumns.ObjectType,
	},
	RepositoryNames.BlogBookMeta: {
		"Id":     BlogKnowledgeBaseMetumColumns.MetaID,
		"KBPost": BlogKnowledgeBaseMetumColumns.KnowledgeBaseID,
		"Key":    BlogKnowledgeBaseMetumColumns.MetaKey,
		"Value":  BlogKnowledgeBaseMetumColumns.MetaValue,
	},
	RepositoryNames.BlogBookDetail: {
		"ContentHtml": BlogKnowledgeBaseDetailColumns.PostContent,
		"Content":     BlogKnowledgeBaseDetailColumns.PostContentFiltered,
	},
	RepositoryNames.BlogBookRelation: {
		"Id":               BlogKnowledgeBaseRelationshipColumns.EntryRelationshipID,
		"PerfumeId":        BlogKnowledgeBaseRelationshipColumns.FromEntryID,
		"PerfumeSectionId": BlogKnowledgeBaseRelationshipColumns.FromSectionID,
		"EntryId":          BlogKnowledgeBaseRelationshipColumns.ToEntryID,
		"EntrySectionId":   BlogKnowledgeBaseRelationshipColumns.ToSectionID,
		"EntryGroup":       BlogKnowledgeBaseRelationshipColumns.ToEntryGroup,
		"EntryOrder":       BlogKnowledgeBaseRelationshipColumns.ToEntryOrder,
		"EntryMeta":        BlogKnowledgeBaseRelationshipColumns.ToEntryMeta,
	},
	RepositoryNames.BlogTerm: {
		"Id":        BlogTermColumns.TermID,
		"Name":      BlogTermColumns.Name,
		"Slug":      BlogTermColumns.Slug,
		"Taxonomy":  BlogTermColumns.Taxonomy,
		"ParentId":  BlogTermColumns.ParentID,
		"GroupId":   BlogTermColumns.TermGroup,
		"Count":     BlogTermColumns.Count,
		"DescHtml":  BlogTermColumns.Description,
		"Desc":      BlogTermColumns.DescriptionFiltered,
		"id":        BlogTermRelationshipColumns.ObjectID,
		"order":     BlogTermRelationshipColumns.TermOrder,
		"sticky":    BlogTermRelationshipColumns.StickyType, // 小写字母开头的都是中间表字段
		"Status":    BlogTermColumns.Status,
		"SortOrder": BlogTermColumns.Sort,
	},
	RepositoryNames.BlogReactionLog: {
		"Id":         BlogReactionLogColumns.ID,
		"PostId":     BlogReactionLogColumns.PostID,
		"PostType":   BlogReactionLogColumns.PostType,
		"UserId":     BlogReactionLogColumns.UserID,
		"Type":       BlogReactionLogColumns.Type,
		"Status":     BlogReactionLogColumns.Status,
		"Count":      BlogReactionLogColumns.Count,
		"CreatedAt":  BlogReactionLogColumns.CreatedAt,
		"CreateDate": BlogReactionLogColumns.CreateDate,
	},
}

var RpcEntityNames = struct { // rpc entities
	BlogAuthor       string
	BlogMedia        string
	BlogPhoto        string
	BlogPage         string
	BlogPageDetail   string
	BlogPageMeta     string
	BlogPost         string
	BlogPostDetail   string
	BlogPostMeta     string
	BlogBook         string
	BlogBookDetail   string
	BlogBookMeta     string
	BlogBookRelation string
	BlogTerm         string
	BlogTermMeta     string
	BlogReactionLog  string
}{
	BlogAuthor:       "blogAuthor",
	BlogMedia:        "blogMedia",
	BlogPhoto:        "blogPhoto",
	BlogPage:         "blogPage",
	BlogPageDetail:   "blogPageDetail",
	BlogPageMeta:     "blogPageMeta",
	BlogPost:         "blogPost",
	BlogPostDetail:   "blogPostDetail",
	BlogPostMeta:     "blogPostMeta",
	BlogBook:         "blogBook",
	BlogBookDetail:   "blogBookDetail",
	BlogBookMeta:     "blogBookMeta",
	BlogBookRelation: "blogBookRelation",
	BlogTerm:         "blogTerm",
	BlogTermMeta:     "blogTermMeta",
	BlogReactionLog:  "blogReactionLog",
}

type ColumnSetting struct {
	Name          string /// rpc column name
	RpcEntityName string
	Id            uint64
	Slug          string
	UriTemplate   string
	Group         uint
	BothWay       bool
	ParentId      uint64
}

var RpcEntityPreloadMap = map[string]map[string]*ColumnSetting{
	RpcEntityNames.BlogAuthor: {},
	RpcEntityNames.BlogMedia:  {},
	RpcEntityNames.BlogPhoto:  {},
	RpcEntityNames.BlogPage: {
		"content": &ColumnSetting{
			Name:          "content",
			RpcEntityName: RpcEntityNames.BlogPageDetail,
		},
	},
	RpcEntityNames.BlogPageDetail: {},
	RpcEntityNames.BlogPageMeta: {
		"fullHead": &ColumnSetting{
			Name: "fullHead",
		},
		"title": &ColumnSetting{
			Name: "title",
		},
		"metaDesc": &ColumnSetting{
			Name: "metaDesc",
		},
	},
	RpcEntityNames.BlogPost: {
		"content": &ColumnSetting{
			Name:          "content",
			RpcEntityName: RpcEntityNames.BlogPostDetail,
		},
	},
	RpcEntityNames.BlogPostDetail: {},
	RpcEntityNames.BlogPostMeta: {
		"fullHead": &ColumnSetting{
			Name: "fullHead",
		},
		"title": &ColumnSetting{
			Name: "title",
		},
		"metaDesc": &ColumnSetting{
			Name: "metaDesc",
		},
		"mediaId": &ColumnSetting{ // ##25.03.14##
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{ // ##25.03.14##
			Name: "_thumbnail_url",
		},
		"viewCount": &ColumnSetting{ // ##25.03.14##
			Name: "_view_count",
		},
		"commentCount": &ColumnSetting{ // ##25.03.14##
			Name: "_comment_count",
		},
		"forwardCount": &ColumnSetting{ // ##25.03.14##
			Name: "_forward_count",
		},
	},
	RpcEntityNames.BlogBook: {
		"content": &ColumnSetting{
			Name:          "content",
			RpcEntityName: RpcEntityNames.BlogBookDetail,
		},
	},
	RpcEntityNames.BlogBookDetail: {},
	RpcEntityNames.BlogBookMeta: {
		"fullHead": &ColumnSetting{
			Name: "fullHead",
		},
		"title": &ColumnSetting{
			Name: "title",
		},
		"metaDesc": &ColumnSetting{
			Name: "metaDesc",
		},
		"perfumeCount": &ColumnSetting{
			Name: "_perfume_count",
		},
		"productCount": &ColumnSetting{
			Name: "_product_count",
		},
		"skuCount": &ColumnSetting{
			Name: "_sku_count",
		},
		"maxProductGems": &ColumnSetting{
			Name: "_max_product_gems",
		},
		"minProductGems": &ColumnSetting{
			Name: "_min_product_gems",
		},
		"likeCount": &ColumnSetting{
			Name: "_like_count",
		},
		"averageRating": &ColumnSetting{
			Name: "_average_rating",
		},
		"ratingCount": &ColumnSetting{
			Name: "_rating_count",
		},
		"ratingTotal": &ColumnSetting{
			Name: "_rating_total",
		},
		"season": &ColumnSetting{
			Name: "_season",
		},
		"popularity": &ColumnSetting{
			Name: "_popularity",
		},
		"backgroundColor": &ColumnSetting{
			Name: "_background_color",
		},
		"fontColorLight": &ColumnSetting{
			Name: "_font_color_light",
		},
		"recommended": &ColumnSetting{
			Name: "recommended",
		},
		"mediaId": &ColumnSetting{ // ##24.12.27##
			Name: "_thumbnail_id",
		},
		"mediaUrl": &ColumnSetting{ // ##24.12.27##
			Name: "_thumbnail_url",
		},
		"viewCount": &ColumnSetting{ // ##24.12.27##
			Name: "_view_count",
		},
		"commentCount": &ColumnSetting{ // ##24.12.27##
			Name: "_comment_count",
		},
		"forwardCount": &ColumnSetting{ // ##24.12.27##
			Name: "_forward_count",
		},
		"reviewCount": &ColumnSetting{ // ##24.12.27##
			Name: "_review_count",
		},
		"year": &ColumnSetting{ // ##24.12.28##
			Name: "_year",
		},
		"gender": &ColumnSetting{ // ##24.12.28##
			Name: "_gender",
		},
		"concentration": &ColumnSetting{ // ##24.12.28##
			Name: "_concentration",
		},
	},
	RpcEntityNames.BlogBookRelation: {
		"brand": &ColumnSetting{
			Id:          14,
			Name:        "brand",
			Slug:        "brands", // 后台使用
			UriTemplate: "/knowledge-base/perfume-brands/",
		},
		"perfume": &ColumnSetting{
			Id:          15,
			Name:        "perfume",
			Slug:        "perfumes",
			BothWay:     true,
			UriTemplate: "/knowledge-base/perfumes/",
			ParentId:    14,
		},
		"nose": &ColumnSetting{
			Id:          16,
			Name:        "nose",
			Slug:        "perfumers",
			UriTemplate: "/knowledge-base/perfumers/",
		},
		"group": &ColumnSetting{
			Id:          17,
			Name:        "group",
			Slug:        "fragrance families",
			UriTemplate: "/knowledge-base/fragrance-families/",
		},
		"note": &ColumnSetting{
			Id:          18,
			Name:        "note",
			Slug:        "notes",
			UriTemplate: "/knowledge-base/fragrance-notes/",
		},
		"top notes": &ColumnSetting{
			Id:          18,
			Name:        "note",
			Slug:        "notes",
			Group:       1,
			UriTemplate: "/knowledge-base/fragrance-notes/",
		},
		"heart notes": &ColumnSetting{
			Id:          18,
			Name:        "note",
			Slug:        "notes",
			Group:       2,
			UriTemplate: "/knowledge-base/fragrance-notes/",
		},
		"base notes": &ColumnSetting{
			Id:          18,
			Name:        "note",
			Slug:        "notes",
			Group:       3,
			UriTemplate: "/knowledge-base/fragrance-notes/",
		},
		"versions": &ColumnSetting{
			Id:          25,
			Name:        "version",
			Slug:        "versions",
			UriTemplate: "/knowledge-base/perfume-versions/",
		},
	},
	RpcEntityNames.BlogTerm:        {},
	RpcEntityNames.BlogTermMeta:    {},
	RpcEntityNames.BlogReactionLog: {},
}
